package com.etc.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.etc.entity.User;

@Controller
@RequestMapping(value="userapi")
public class UserController {
	
	@Resource(name="user")
	private User u;
	
	/**
	 * 得到用户信息，用户登录了才可以进行拦截
	 * @param model
	 * @return
	 */
	@RequestMapping(value="listUser")
	public String getUser(Model model){
		model.addAttribute("u", u);
		return "user";
	}
	
	/**
	 * 用户登录请求
	 * @param model
	 * @param name
	 * @param session
	 * @return
	 */
	@RequestMapping(value="login")
	public String login(Model model,String name,HttpSession session){
		session.setAttribute("name", name);
		return "user";
	}

}
